<?php
		/*$mPDF1 = Yii::app()->ePdf->mpdf();
 
        # You can easily override default constructor's params
        */$mPDF1 = Yii::app()->ePdf->mpdf('c','A4','','',7,7,30,40,15,5);
 
        # render (full page)
        //$mPDF1->WriteHTML($this->render('viewPDF', array(), true));
 
        # Load a stylesheet
        $stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/pdf.css');
        $mPDF1->WriteHTML($stylesheet, 1);
 
        # renderPartial (only 'view' of current controller)
		
		//--------------------------------------------------------------------------------------------------------
		
        $fullname=Yii::app()->session['fullname'] ;

		$currency='  ( $ )';
		$tempCurr=FormatingNumber::currency($modelInvoice->currency);
		if($modelInvoice->currency=="IDR"){
			$currency='  ( Rp )';
		}
		
		$pdf="
		
<style>
.test {
	border:0.1mm solid #220044; 
}
</style>
			
<!--mpdf
<htmlpageheader name='myHTMLHeader1'>
<img src='images/bra_int.jpg' height='100' width='130'>
</htmlpageheader>

<htmlpagefooter name='myHTMLFooter'>
<table style='font-size: 8pt;' width=100%>
	<tr>
		<td>
		<center>
			<b>PT. Bralink Intertrade</b> <br>
			jl. Raya Paso No.20,Jagakarsa, Jakarta Selatan - Indonesia 12620 <br>
			Phone: +62-21 788 33 279, +62-21 788 40 659, Fax: +62-21 788 30 341<br>
			Website : www.ledlight.co.id
		</center>
	</tr>
</table>
</htmlpagefooter>
mpdf-->


<!-- set the headers/footers - they will occur from here on in the document -->
<!--mpdf
<sethtmlpageheader name='myHTMLHeader1' page='O' value='on' show-this-page='1' />
<sethtmlpagefooter name='myHTMLFooter' page='O' value='on' show-this-page='1' />
mpdf-->

<div class='titlePO'>
INVOICE<br>
</div>


<div>
	<table class='tableView' width='100%'>
		<tr>
			<td id='customer' colspan='3'>
				<table class='customerName' width='100%'>
					<tr>
						<td><b>Bill To : </b></td>
					</tr>
				</table>
				
				<table class='customerDetail' width='100%'>
					<tr>
						<td><b> $modelCustomer->customer</b></td>
					</tr>
					<tr>
						<td>$modelCustomer->address</td>
					</tr>
					<tr>
						<td>$modelCustomer->phone</td>
					</tr>
				</table>
			</td>
			<td  colspan='2'>
				<table width='280'>
					<tr>
						<td><b> Invoice No</b></td> <td>$modelInvoice->invoice_no</td>
					</tr>
					<tr>
						<td>Date</td> <td>$modelInvoice->date_invoice</td>
					</tr>
					<tr>
						<td>Currency</td> <td>$modelInvoice->currency</td>
					</tr>
					<tr>
						<td>Due Date</td> <td>$modelInvoice->due_date</td>
					</tr>
					<tr>
						<td>PO Reference</td> <td>$modelInvoice->PO_reference</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr bgcolor='#66CC99'>
			<td id='row2' class='columnView' width='10%'>No.</td>
			<td id='row2' class='columnView' width='30%'>Description</td>
			<td id='row2' class='columnView' width='5%'>Unit</td>
			<td id='row2' class='columnView' width='20%'>Amount ".$currency."</td>
			<td id='row2' class='columnView' width='20%'>Total Amount ".$currency."</td>
		</tr>";
		$total=0;
		$subTotal=0;
	for($i=0;$i<count($modelProduct);$i++){
		$total=$modelDetail[$i]->qty*$modelProduct[$i]->unit_sell*$tempCurr;
		$subTotal+=$total;
		$pdf.="<tr>
			<td id='u_row2' class='columnView' width='5%'>".($i+1)."</td>
			<td class='columnView' width='55%'>
				<table>
					<tr>
						<td><b>".$modelProduct[$i]->brands."</b></td>
					</tr>
					<tr>
						<td>".$modelProduct[$i]->product_pn."</td>
					</tr>
				</table>
			</td>
			<td id='row2' class='columnView' width='10%'>".$modelDetail[$i]->qty."</td>
			<td id='row2' class='columnView' width='15%'> ".number_format($modelProduct[$i]->unit_sell*$tempCurr,2,'.',',')."</td>
			<td id='row2' class='columnView' width='15%'> ".number_format($total,2,'.',',')."</td>
		</tr>";
	}
	$pdf.="<tr>
			<td height='25px' style='border-bottom:none;' colspan='3' align='left'><b>Say</b></td>
			<td id='u_row2' class='columnView'><b>Sub-Total ".$currency."</b></td>
			<td id='u_row2' class='columnView'><b>".number_format($subTotal,2,'.',',')."</b></td>
		</tr>
		<tr>
			<td colspan='5' align='left'><b><i># ".NumberText::makewords($subTotal,$modelInvoice->currency)." #</i></b></td>
		</tr>

		<tr>
			<td colspan='3' align='left'><br><b><i>Pay :</i></b></td>
			<td colspan='2' align='center'><b> PT Bralink Intertrade </b></td>
		</tr>

		<tr>
			<td colspan='5' align='left'>
			<br>
				<b>".$modelInvoice->account->name."</b><br>
				".$modelInvoice->account->bank." ( ".$modelInvoice->account->swift_code." ) <br>
				".$modelInvoice->account->desc." <br>
				Account : <b>".$modelInvoice->account->number." ($modelInvoice->currency)</b>
			<br><br>
			<br>
			</td>
		</tr>
		<tr>
			<td colspan='3'>&nbsp;</td>
			<td colspan='2' align='center'>
				$fullname #
			</td>
		</tr>

	</table>
</div>
		
		
		
		";
		
		//--------------------------------------------------------------------------------------------------------
        $mPDF1->WriteHTML($pdf);
 		$mPDF1->AddPage();
        # Renders image
        //$mPDF1->WriteHTML(CHtml::image(Yii::getPathOfAlias('webroot.css') . '/bg.gif' ));
 
        # Outputs ready PDF
		//$mPDF1->SetDisplayMode('fullpage');
        $mPDF1->Output();//Output('testing.pdf','D');
		exit;
?>